package com.myapp.struts.action;

import com.myapp.hibernate.model.Boxeador;
import com.myapp.hibernate.util.BoxeadorUtil;
import com.myapp.struts.form.BoxeadoresForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author jiglrom
 */
public class ModificarBoxeadorAction extends org.apache.struts.action.Action {

    private static final String SUCCESS = "success";

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        BoxeadoresForm formulario = (BoxeadoresForm)form;
        BoxeadorUtil boxeadorUtil = new BoxeadorUtil();
        Boxeador b = boxeadorUtil.obtenerBoxeador(formulario.getIdBoxeador());
        formulario.setIdBoxeador(b.getIdBoxeador());
        formulario.setNombre(b.getNombre());
        formulario.setApellidos(b.getApellidos());
        formulario.setCganados(b.getCGanados());
        formulario.setCperdidos(b.getCPerdidos());
        return mapping.findForward(SUCCESS);
    }
}
